<?xml version="1.0" encoding="utf-8" ?>
<taskrunner name="is.localdb.attached" version="1.0" date="2008-10-30" maxthreads="1">

  <!-- 
    checks whether accessserver and diagswdlsession are attached or not. If both databases are attached
    then the global property ¤{localdb.is.attached} is set to true otherwise it's set to false.
  
  -->

  <includes>
    <file name="vida.install.settings.xml" />
  </includes>

  <properties>
    <property key="run.start.sqlexpress.service" value="true"/>
    <property key="run.update.accessserver" value="true"/>
    <property key="run.diagswdlsession.is.attached" value="true"/>
    <property key="run.accessserver.is.attached" value="true"/>
  </properties>
  <tasks>
    
    <task name="start.sqlexpress.service"  typename="@WindowsServiceCommand" run="${run.start.sqlexpress.service}">
      <parameters>
        <parameter name="server.name" value=""/>
        <parameter name="service.name" value="MSSQL$${sqlserver.instance.name}"/>
        <parameter name="command" value="start"/>
        <parameter name="throwException" value="false"/>
      </parameters>
    </task>

    <task name="accessserver.is.attached" typename="@SqlServerManagement.IsDatabaseAttached" run="${run.accessserver.is.attached}">
      <dependencies list="start.sqlexpress.service"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="database" value="${db.accessserver.name}"/>
        <!-- out parameters -->
        <parameter name="output.value" value="localdb.is.attached"/>

      </parameters>
    </task>

    <task name="diagswdlsession.is.attached" condition="¤{localdb.is.attached}=true" typename="@SqlServerManagement.IsDatabaseAttached" run="${run.diagswdlsession.is.attached}">
      <dependencies list="accessserver.is.attached,start.sqlexpress.service"/>
      <parameters>
        <parameter name="server" value="${sqlserver.local.server}"/>
        <parameter name="userid" value="${sqlserver.local.userid}"/>
        <parameter name="password" value="${sqlserver.local.password}"/>
        <parameter name="database" value="${db.diagswdlsession.name}"/>
        <!-- out parameters -->
        <parameter name="output.value" value="localdb.is.attached"/>

      </parameters>
    </task>

  </tasks>
</taskrunner>